import { Module, ActionContext } from 'vuex';
import { GlobalDataProps } from './index';
// 用户信息
export interface UserProps {
  isLogin: boolean;
  userName?: string;
}

const user: Module<UserProps, GlobalDataProps> = {
  state: {
    isLogin: false,

    userName: localStorage.getItem('token') || ''
  },
  mutations: {
    login(state) {
      state.isLogin = true;
    },
    logout(state) {
      state.isLogin = false;
      state.userName = '';
      localStorage.removeItem('token');
    }
  },
  actions: {}
};

export default user;
